import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/pages/login'
import Home from '@/pages/home'
import System from '@/pages/system'
import File from '@/pages/system/file'
import Voice from '@/pages/system/voice'
import Set from '@/pages/system/set'
import error404 from '@/pages/error/404'

Vue.use(Router)

export const constantRoutes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    meta: {
      requireAuth: true // 添加该字段，表示进入这个路由是需要登录的
    }
  }
]

export const asyncRoutes = [{
  path: '/system',
  component: System,
  meta: {
    requireAuth: true
  },
  children: [
    {
      path: 'voice',
      name: 'Voice',
      component: Voice,
      meta: {
        requireAuth: true
      }
    },
    {
      path: 'file',
      name: 'File',
      component: File,
      meta: {
        requireAuth: true
      }
    },
    {
      path: 'set',
      name: 'Set',
      component: Set,
      meta: {
        requireAuth: true
      }
    }
  ]
}, {
  path: '*',
  name: '404',
  component: error404
}]

export default new Router({
  routes: constantRoutes
})
